
<html><HEAD>
<LINK REL=STYLESHEET HREF="default.css" TYPE="text/css">
<TITLE>
Notes on using the SNC interface</TITLE>
</HEAD>
<BODY>

<!-- Header -->
<p class="ancestor" align="right"><A HREF="connpbp61.htm">Previous</A>&nbsp;&nbsp;<A HREF="connpbp63.htm" >Next</A>
<!-- End Header -->
<A NAME="BCGGJIDI"></A><h1>Notes on using the SNC interface</h1>
<A NAME="TI1303"></A><h4>Using the DBHandle PowerScript function</h4>
<A NAME="TI1304"></A><p>The <b>DBHandle</b> function on the Transaction
object returns the IUnknown* interface of the current session
object. You can use this interface to query any interface in the
session object. The interface is not locked by <b>pIUnknown-&gt;Addref()</b> in
PowerBuilder, therefore you should not call the <b>pIUnknown-&gt;Release()</b> to
free the interface after using it.</p>
<A NAME="TI1305"></A><h4>SQL batch statements</h4>
<A NAME="TI1306"></A><p>The SNC interface supports SQL batch statements. However,
they must be enclosed in a <b>BEGIN...END</b> block
or start with the keyword <b>DECLARE</b>:</p>
<A NAME="TI1307"></A><p><A NAME="TI1308"></A>
<ul>
<li class=fi> Enclosed in a <b>BEGIN...END</b> block:<p><PRE> BEGIN<br>INSERT INTO t_1 values(1, 'sfdfs')<br>INSERT INTO t_2 values(1, 'sfdfs')<br>SELECT * FROM t_1<br>SELECT * FROM t_2<br>END</PRE></li>
<li class=ds>Starting with the keyword <b>DECLARE</b>:<p><PRE> DECLARE @p1 int, @p2 varchar(50)<br>SELECT  @p1 = 1<br>EXECUTE  sp_4 @p1, @p2 OUTPUT<br>SELECT @p2  AS  'output'</PRE>
</li>
</ul>
</p>
<A NAME="TI1309"></A><p>You can run the batch of SQL statements in the Database painter or
in PowerScript. For example:<p><PRE> String batchSQL //contains a batch of SQL statements<br>DECLARE my_cursor DYNAMIC CURSOR FOR SQLSA ;<br>PREPARE SQLSA FROM :batchSQL ;<br>OPEN DYNAMIC my_cursor ;<br> <br>//first result set<br>FETCH my_cursor INTO . . .<br> <br>//second result set<br>FETCH my_cursor INTO . . <br>. . .<br>CLOSE my_cursor ;</PRE></p>
<A NAME="TI1310"></A><h4>Connection pooling</h4>
<A NAME="TI1311"></A><p>The SNC interface pools connections automatically using OLE
DB pooling. To disable OLE DB pooling, type the following in the
Extended Properties box on the Connection tab page in the Database
Profile Setup dialog box: <p><PRE> OLE DB Services=-4</PRE></p>
<A NAME="TI1312"></A><p>You can also type the following statement in code:<p><PRE> ProviderString='OLE DB Services=-4')</PRE></p>
<A NAME="TI1313"></A><h4>Triggers and synonyms in the Database painter</h4>
<A NAME="TI1314"></A><p>In the Objects view for SNC profiles in the Database painter,
triggers display for tables in the Tables folder and Microsoft SQL
Server 2005 synonyms display for tables and views.</p>

